import requests

def get_weather():
    """
    根据IP获取天气状况
    """

    url = "https://v.api.aa1.cn/api/api-tianqi-6/"
    response = requests.get(url)
    data = response.json()
    # code = data["code"]
    # city = data["city"]
    # date = data["date"]
    # temperature = data["temperature"]
    # weather = data["weather"]
    # manner = data["manner"]
    # air_quality = data["air_uality"]
    return data
def get_everyday_rhesis():
    """
    获取每日一言
    """
    url = "http://www.wudada.online/Api/MrYy"
    response = requests.get(url)
    data = response.json()
    hitokoto = data["data"]["hitokoto"]
    from_text = data["data"]["from"]
    return hitokoto,from_text

def get_ip_location(ip):
    """
    获取IP归属地
    """
    url = f"http://106.14.221.171:808/gdAreacode/search?ip={ip}"
    response = requests.get(url)
    data = response.json()
    return data["data"]


if __name__ == "__main__":
    dd=get_everyday_rhesis()
    dt=get_ip_location('1.14.68.207')
    df=get_weather()
    print(dd,dt,df)
